package com.boot.redis.web;

import com.boot.redis.model.TestData;
import com.boot.redis.service.TestDateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(value = "/test")
public class TestDateController {

    @Autowired
    private TestDateService testDateService;

    @RequestMapping(value = "/getlist",method = RequestMethod.GET)
    @ResponseBody
    public List<TestData>list(){
        return testDateService.getTestDateList();
    }


    @RequestMapping(value = "/getlistPage",method = RequestMethod.GET)
    @ResponseBody
    public List<TestData>list(Integer page,Integer size){
        return testDateService.getTestDateListPage(page,size);
    }



    @RequestMapping(value = "/saveTestData",method = RequestMethod.GET)
    @ResponseBody
    public void saveTestData(TestData testData){
         testDateService.saveTestData(testData);
    }


    @RequestMapping(value = "/delete",method = RequestMethod.GET)
    @ResponseBody
    public void deleteTestDataById(TestData testData){
        testDateService.deleteTestDataById(testData);
    }

    @RequestMapping(value = "/update",method = RequestMethod.GET)
    @ResponseBody
    public void updateTestDataById(TestData testData){
        testDateService.updateTestDataById(testData);
    }
}
